home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / DECFRAME.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  185 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.8  $
  6. //
  7. // Definition of class TDecoratedFrame, a TFrameWindow that can manage
  8. // decorations around the client window.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_DECFRAME_H)
  11. #define OWL_DECFRAME_H
  12.  
  13. #if !defined(OWL_FRAMEWIN_H)
  14. # include <owl/framewin.h>
  15. #endif
  16. #if !defined(OWL_LAYOUTWI_H)
  17. # include <owl/layoutwi.h>
  18. #endif
  19.  
  20. #if defined(BI_NAMESPACE)
  21. namespace OWL {
  22. #endif
  23.  
  24. const int IDW_TOOLBAR       = 32041;  // Standard toolbar child window ID
  25.  
  26. //
  27. // General use absolute 2-D rectangular location enum
  28. // [Used mainly to describe the locations of a gadgetwindow, such a toolbar
  29. //  or statusbar, within a decorated frame]
  30. //
  31. enum TAbsLocation {
  32.   alNone   = 0,          // No location specified
  33.   alTop    = 1,          // Refers to top edge of frame
  34.   alBottom = 2,          // Refers to bottom edge of frame
  35.   alLeft   = 3,          // Refers to left edge of frame
  36.   alRight  = 4,          // Refers to right edge of frame
  37. };
  38.  
  39. //
  40. // enum THintText
  41. // ~~~~~~~~~~~~~~
  42. enum THintText {
  43.   htStatus    = 0x0001,         // Text displayed on status bar
  44.   htTooltip   = 0x0002,         // Shorter text displayed in a tooltip
  45.   htUserDefined                 // Can be used when enhancing 'GetHintText'
  46. };                              // to support balloon text etc..
  47.  
  48. // Generic definitions/compiler options (eg. alignment) preceeding the 
  49. // definition of classes
  50. #include <services/preclass.h>
  51.  
  52. //
  53. // class TDecoratedFrame
  54. // ~~~~~ ~~~~~~~~~~~~~~~
  55. // Automatically positions its client window so that it is the same size as
  56. // the client rect
  57. //
  58. // You can add additional decorations like toolbars and status lines
  59. //
  60. class _OWLCLASS TDecoratedFrame : virtual public TFrameWindow,
  61.                                           public TLayoutWindow {
  62.   public:
  63.     TDecoratedFrame(TWindow*        parent,
  64.                     const char far* title,
  65.                     TWindow*        clientWnd,
  66.                     bool            trackMenuSelection = false,
  67.                     TModule*        module = 0);
  68.  
  69.     // Enumeration describing the possible locations of a Gadgetwindow
  70.     // [Used mainly for location of Toolbar and Statusbar standalone
  71.     //  and in the context of docking windows]
  72.     //
  73.     enum TLocation {
  74.       None   = alNone,            // No location specified
  75.       Top    = alTop,             // Refers to top edge of frame
  76.       Bottom = alBottom,          // Refers to bottom edge of frame
  77.       Left   = alLeft,            // Refers to left edge of frame
  78.       Right  = alRight,           // Refers to right edge of frame
  79.     };
  80. //    typedef TAbsLocation TLocation;
  81.  
  82.     virtual void  Insert(TWindow& decoration, TLocation location = Top);
  83.  
  84.     // Hint/Status/Tip text
  85.     //
  86.     virtual int     GetHintText(uint id, char* buf, int size,
  87.                                 THintText hintType) const;
  88.  
  89.     // Override TFrameWindow member function to give decorations an opportunity
  90.     // to do pre-processing (e.g. mnemonic access)
  91.     //
  92.     bool      PreProcessMsg(MSG& msg);
  93.     TWindow*  SetClientWindow(TWindow* clientWnd);
  94.  
  95.   protected:
  96.     bool      GetTrackMenuSelection() const;
  97.     void      SetTrackMenuSelection(bool tr=true);
  98.  
  99.     uint      GetMenuItemId() const;
  100.     void      SetMenuItemId(uint menuitemid);
  101.  
  102.     // Override TWindow virtuals
  103.     //
  104.     void      SetupWindow();
  105.     void      RemoveChild(TWindow* child);
  106.  
  107.     // Automatic showing/hiding of tool bars and status bars
  108.     //
  109.     TResult   EvCommand(uint id, HWND hWndCtl, uint notifyCode);
  110.     void      EvCommandEnable(TCommandEnabler& ce);
  111.  
  112.     // Message response functions
  113.     //
  114.     void      EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu);
  115.     void      EvEnterIdle(uint source, HWND hWndDlg);
  116.     void      EvSize(uint sizeType, TSize& size);
  117.  
  118.   protected_data:
  119.     bool      TrackMenuSelection;       // track menu select for status hints?
  120.     uint      MenuItemId;               // id of current menu selection
  121.  
  122.   private:
  123.     void      InsertAtTop(TWindow& decoration, TWindow* insertAbove);
  124.     void      InsertAtBottom(TWindow& decoration, TWindow* insertBelow);
  125.     void      InsertAtLeft(TWindow& decoration, TWindow* insertLeftOf);
  126.     void      InsertAtRight(TWindow& decoration, TWindow* insertRightOf);
  127.  
  128.     bool      SettingClient;
  129.  
  130.     // Hidden to prevent accidental copying or assignment
  131.     //
  132.     TDecoratedFrame(const TDecoratedFrame&);
  133.     TDecoratedFrame& operator =(const TDecoratedFrame&);
  134.  
  135.   DECLARE_RESPONSE_TABLE(TDecoratedFrame);
  136.   DECLARE_STREAMABLE(_OWLCLASS, TDecoratedFrame, 1);
  137. };
  138.  
  139. // Generic definitions/compiler options (eg. alignment) following the 
  140. // definition of classes
  141. #include <services/posclass.h>
  142.  
  143. #if defined(BI_NAMESPACE)
  144. } // namespace OWL
  145. #endif
  146.  
  147. //----------------------------------------------------------------------------
  148. // Inline implementations
  149. //
  150.  
  151. //
  152. // Returns true if the decorated frame is tracking the menu selections.
  153. // Sends a message to the status bar to display the hint text.
  154. //
  155. inline bool
  156. TDecoratedFrame::GetTrackMenuSelection() const {
  157.   return TrackMenuSelection;
  158. }
  159.  
  160. //
  161. // Set the flag for tracking menu selection.
  162. //
  163. inline void
  164. TDecoratedFrame::SetTrackMenuSelection(bool tr) {
  165.   TrackMenuSelection = tr;
  166. }
  167.  
  168. //
  169. // Return cached id of the current menu item.
  170. //
  171. inline uint
  172. TDecoratedFrame::GetMenuItemId() const {
  173.   return MenuItemId;
  174. }
  175.  
  176. //
  177. // Set the cached id of the current menu item.
  178. //
  179. inline void
  180. TDecoratedFrame::SetMenuItemId(uint menuitemid) {
  181.   MenuItemId = menuitemid;
  182. }
  183.  
  184. #endif  // OWL_DECFRAME_H
  185.